package com.fourtwenty.hemptress.plugin.disable;

import com.fourtwenty.hemptress.BotResponse;
import com.fourtwenty.hemptress.BotResponse.Type;
import com.fourtwenty.hemptress.PluginEventBot;
import com.fourtwenty.hemptress.plugin.annotate.Plugin;
import com.fourtwenty.hemptress.plugin.annotate.events.OnCommand;
import com.fourtwenty.hemptress.plugin.annotate.parameters.Params;
import com.fourtwenty.hemptress.plugin.annotate.parameters.Reply;

@Plugin
public class Disable {
	private PluginEventBot bot;
	
	public Disable(PluginEventBot bot) {
		this.bot = bot;
	}

	@OnCommand("disable")
	public BotResponse disable(@Params String params, @Reply String reply) {
		switch(bot.getLoader().getPluginStatus(params.trim().toLowerCase())) {
			case DISABLED:
				return new BotResponse(reply, "Plugin " + params + " is already disabled", Type.MESSAGE);
			case ENABLED:
				bot.getLoader().disablePlugin(params.trim().toLowerCase());
				return new BotResponse(reply, "Plugin " + params + " is now disabled", Type.MESSAGE);
			case NONE:
				return new BotResponse(reply, "Plugin " + params + " was not detected", Type.MESSAGE);
		}
		
		return new BotResponse(reply, "Something went wrong!", Type.MESSAGE);
	}
	
	@OnCommand("enable")
	public BotResponse enable(@Params String params, @Reply String reply) {
		switch(bot.getLoader().getPluginStatus(params.trim().toLowerCase())) {
			case ENABLED:
				return new BotResponse(reply, "Plugin " + params + " is already enabled", Type.MESSAGE);
			case DISABLED:
				bot.getLoader().enablePlugin(params.trim().toLowerCase());
				return new BotResponse(reply, "Plugin " + params + " is now enabled", Type.MESSAGE);
			case NONE:
				return new BotResponse(reply, "Plugin " + params + " was not detected", Type.MESSAGE);
		}
		
		return new BotResponse(reply, "Something went wrong!", Type.MESSAGE);
	}
	
}
